﻿using MediatR;
using Production_Set.API.Application.Commands.Orderers;
using Return.Enum;
using SlaughterItem.Common.Infrastructures.Interfaces;
using THE_WIND_RISES.Common.Domans.Produce.Order;
using THE_WIND_RISES.Common.Domans.Warehousing;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Set.API.Application.Commands.Warehousings
{
    public class OrderTineDelHandler : IRequestHandler<OrderTineDelCommend, Result>
    {
        private readonly IBaseRepository<OrderTine> OrderTine;

        public OrderTineDelHandler(IBaseRepository<OrderTine> OrderTine)
        {
            this.OrderTine = OrderTine;
        }

        public async Task<Result> Handle(OrderTineDelCommend request, CancellationToken cancellationToken)
        {
            var results = new Result() { Code = (int)CommonErrorCodes.Delete };

            string sql = "UPDATE OrderTine SET IsDelete=1 WHERE OrderTineId=" + request.OrderTineId;
            var list = OrderTine.Update(sql, results);
            if (list != null)
            {
                results.Code = (int)CommonErrorCodes.Success;
                results.Msg = "删除成功";
            }

            return results;
        }
    }
}
